Hackerrank – Problem Statement
A description of the problem can be found on Hackerrank.
Solution
For every input line:
- divide into character pairs
- reverse order of characters
- concat the pairs it into the one string
I created solution in:
All solutions are also available on my GitHub.
Scala
1 2 3 4 5 |
object StringOPermute extends App { val lines = Source.stdin.getLines().drop(1) val linePairs = lines.map(_.grouped(2).map(_.reverse).toList.flatten) println(linePairs.mkString("\n")) } |